﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.Register.Application.Commonds.LoginCommond;
using Traceability.Register.ErrorCode.Result;

namespace Traceability.Register.Read.API.Controllers
{
    /// <summary>
    /// 登录控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LoginsController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator">中介者</param>
        public LoginsController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="param">请求</param>
        /// <returns>返回任务</returns>
        [HttpPost]
        public async Task<ApiResult> GetLogin(UserLoginCommond param)
        {
            return await mediator.Send(param);
        }
    }
}
